package cn.ptu.pmaa.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface LoginRegMapper {
    @Select("select count(*) from admin where adminid=#{id} and adminpwd=#{pwd}")
    public int adminlogin(@Param("id") String id, @Param("pwd") String pwd);

    @Select("select count(*) from teacher where teacherid=#{id} and teacherpwd=#{pwd}")
    public int teacherlogin(@Param("id") String id, @Param("pwd") String pwd);

    @Select("select count(*) from student where studentid=#{id} and studentpwd=#{pwd}")
    public int studentlogin(@Param("id") String id, @Param("pwd") String pwd);

    @Select("select teacheremail from teacher where teacherid=#{id}")
    public String getEmailFromTeacher(@Param("id") String id);

    @Select("select studentemail from student where studentid=#{id}")
    public String getEmailFromStudent(@Param("id") String id);

    @Update("UPDATE student SET studentpwd=#{pwd} WHERE studentid=#{id}")
    public int studentEditPass(@Param("id")String id,@Param("pwd")String pwd);

    @Update("UPDATE teacher SET teacherpwd=#{pwd} WHERE teacherid=#{id}")
    public int teacherEditPass(@Param("id")String id,@Param("pwd")String pwd);

    @Update("UPDATE admin SET adminpwd=#{pwd} WHERE adminid=#{id}")
    public int adminEditPass(@Param("id")String id,@Param("pwd")String pwd);

}
